package top.superflow.lang

import java.lang.reflect.{GenericArrayType, ParameterizedType, Type}

object ReflectUtils {


  def isSingleGenericType(tp : Type, expectedGenericType : Class[_]) : Boolean = {

    if(tp == null || expectedGenericType == null){
      return false
    }

    if(tp.isInstanceOf[ParameterizedType]){
      val actualTypeArguments = tp.asInstanceOf[ParameterizedType].getActualTypeArguments
      if(actualTypeArguments.size != 1){
        return false
      }

      return actualTypeArguments.apply(0) == expectedGenericType
    }

    return false


  }
}
